/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ee.persistence.spec;

import java.util.HashMap;
import java.util.List;
import javax.persistence.Query;
import org.ee.persistence.exception.NotFoundException;
import org.ee.persistence.exception.NotUniqueException;
import org.ee.persistence.exception.StoredProcedureException;

/**
 *
 * @author Gabriel Bran <gbran.u@gmail.com>
 */
public interface QueryTemplate {

    //
    // Querys Nativos
    //
    
    public Object[] nativeQueryResult(String sqlQuery, List<Object> parameters) throws NotFoundException, NotUniqueException;

    public Object[] nativeQueryResult(String sqlQuery, HashMap<Integer, Object> parameters) throws NotFoundException, NotUniqueException;

    public <T> T nativeQueryResult(String sqlQuery, HashMap<Integer, Object> parameters, Class<T> resultClass) throws NotFoundException, NotUniqueException;

    public <T> List<T> nativeQuery(String sqlQuery, HashMap<Integer, Object> parameters, Class<T> resultClass);

    public <T> List<T> nativeQuery(String sqlQuery, HashMap<Integer, Object> parameters, Class<T> resultClass, int firtsResult, int maxResult);

    public List<Object[]> nativeQuery(String sqlQuery, HashMap<Integer, Object> parameters);

    public List<Object[]> nativeQuery(String sqlQuery, HashMap<Integer, Object> parameters, int firtsResult, int maxResult);

    //
    // Querys Nativos Nombrados
    //
    
    public <T> T namedNativeQueryResult(String queryName, HashMap<Integer, Object> parameters, Class<T> resultClass) throws NotFoundException, NotUniqueException;

    public Object[] namedNativeQueryResult(String queryName, List<Object> parameters) throws NotFoundException, NotUniqueException;

    public Object[] namedNativeQueryResult(String queryName, HashMap<Integer, Object> parameters) throws NotFoundException, NotUniqueException;

    public List<Object[]> namedNativeQuery(String queryName, HashMap<Integer, Object> parameters);

    public <T> List<T> namedNativeQuery(String queryName, HashMap<Integer, Object> parameters, Class<T> resultClass);

    public List<Object[]> namedNativeQuery(String queryName, HashMap<Integer, Object> parameters, int firtsResult, int maxResult);

    public <T> List<T> namedNativeQuery(String queryName, HashMap<Integer, Object> parameters, Class<T> resultClass, int firtsResult, int maxResult);

    public void namedNativeQueryUpdate(String queryName, HashMap<Integer, Object> parameters);

    //
    // Procedimientos almacenados
    //
    
    public <T> T storeProcedureResult(String procedureName, HashMap<String, Object> parameters, Class<T> resultClass) throws StoredProcedureException;

    //
    // Querys Nombrados
    //
    
    public <T> T namedQueryResult(String queryName, HashMap<String, Object> parameters, Class<T> resultClass) throws NotFoundException, NotUniqueException;

    public <T> List<T> namedQuery(String queryName, HashMap<String, Object> parameters, Class<T> resultClass);

    public <T> List<T> namedQuery(String queryName, HashMap<String, Object> parameters);

    public <T> List<T> namedQuery(String queryName, HashMap<String, Object> parameters, int firtsResult, int maxResult);

    public <T> List<T> namedQuery(String queryName, HashMap<String, Object> parameters, Class<T> resultClass, int firtsResult, int maxResult);

    //
    // JPQL Querys
    //
    
    public <T> T jpqlResult(String jpqlQuery, HashMap<String, Object> parameters, Class<T> resultClass) throws NotFoundException, NotUniqueException;

    public <T> List<T> jpqlQuery(String jpqlQuery, HashMap<String, Object> parameters);

    public <T> List<T> jpqlQuery(String jpqlQuery, HashMap<String, Object> parameters, int firtsResult, int maxResult);

    public <T> List<T> jpqlQuery(String jpqlQuery, HashMap<String, Object> parameters, Class<T> resultClass);

    public <T> List<T> jpqlQuery(String jpqlQuery, HashMap<String, Object> parameters, Class<T> resultClass, int firtsResult, int maxResult);

    //
    // Establecer parametros
    //
    
    public <T extends Query> T setQueryParameters(T query, List<Object> parameters);

    public <T extends Query> T setQueryParameters(T query, List<Object> parameters, int firstResult, int maxResult);

    public <T extends Query> T setQueryParameters(T query, HashMap<?, Object> parameters);

    public <T extends Query> T setQueryParameters(T query, HashMap<?, Object> parameters, int firtsResult, int maxResult);

}
